import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.InputMismatchException;
import java.lang.IndexOutOfBoundsException;

public class notepad {
	private LinkedList<String> A = new LinkedList<String>();
	private static int Count = 0;

	private int integerInput(int Border) {
		Scanner sc = new Scanner(System.in);

		int n;
		while (true) {
			try {
				n = sc.nextInt();
				if (n > Border || n <= 0) {
					System.out.println("重新输入");
					sc = new Scanner(System.in);
					continue;
				}
				return n;

			} catch (InputMismatchException I) {
				System.out.println("重新输入");
				sc = new Scanner(System.in);
			} catch (IndexOutOfBoundsException I) {
				System.out.println("重新输入");
				sc = new Scanner(System.in);
			}

		}

	}

	public void add() {
		Scanner sc = new Scanner(System.in);
		System.out.println("输入：");
		String s = sc.nextLine().toString();
		A.add(s);
		Count++;

	}

	public void delete() {

		if (A.size() == 0) {
			System.out.println("无记录");
		} else {
			System.out.println("输入要删除的条目：(共有" + Count + "条)");
			int n = integerInput(A.size());
			A.remove(n - 1);
			Count--;
		}
	}

	public void printAll() {
		ListIterator<String> iter = A.listIterator();
		int n = 1;
		System.out.println("内容：");
		while (iter.hasNext()) {
			String s = iter.next();
			System.out.println(n + ": " + s);
			n++;

		}

	}

	public void consult() {

		if (A.size() == 0) {
			System.out.println("无记录");
		} else {
			System.out.println("输入要查询的条目：(共有" + Count + "条)");
			int n = integerInput(A.size());
			String s = A.get(n - 1);
			System.out.println(n + ": " + s);
		}

	}

	public void revise() {
		if (A.size() == 0) {
			System.out.println("无记录");
		} else {
			System.out.println("输入要修改的条目：(共有" + Count + "条)");
			int n = integerInput(A.size());
			System.out.println("输入要修改的内容：");
			Scanner sc = new Scanner(System.in);
			String s = sc.nextLine();
			A.set(n-1, s);
		}
	}

	

}
